package com.example.mapper;

import com.example.pojo.Clazz;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ClazzMapper {
    // 查询所有班级
    @Select("select * from clazz")
    List<Clazz> findAll();
    // 添加班级
    @Insert("insert into clazz(name,room,begin_date,end_date,master_id,subject,create_time,update_time) values(#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void save(Clazz clazz);
    // 查询班级总数
    @Select("select count(*) from clazz")
    Long count();
    // 分页查询班级
    @Select("select * from clazz limit #{start},#{pageSize}")
    List<Clazz> list(Integer start, Integer pageSize);
    // 删除班级

    void delete(Integer id);
    //根据ID查询班级
    @Select("select * from clazz where id = #{id}")
    Clazz getById(Integer id);
    // 修改班级
    @Insert("update clazz set name = #{name},room = #{room},begin_date = #{beginDate},end_date = #{endDate},master_id = #{masterId},subject = #{subject},create_time=#{createTime}, update_time = #{updateTime} where id = #{id}")
    void update(Clazz clazz);
}
